package com.ucode.application.form.acis;

import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.ucode.acis.mode.Offprint;
import com.ucode.springboot.starter.web.validator.group.AddGroup;
import com.ucode.springboot.starter.web.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value="单行本")
@SuppressWarnings("serial")
public class OffprintForm implements Serializable{

    @ApiModelProperty(value = "作品Id",required=true)
    @NotNull(message="作品不能为空", groups = {AddGroup.class,UpdateGroup.class})
    private Long worksId;
    
    @ApiModelProperty(value = "名称",required=true)
    @NotBlank(message = "名称不能为空", groups = {AddGroup.class,UpdateGroup.class})
    @Length(max=50,message = "名称最大50个字符", groups = {AddGroup.class,UpdateGroup.class})
    private String name;

    @ApiModelProperty(value = "作者",required=false)
    @Length(max=100,message = "作者最大100个字符", groups = {AddGroup.class,UpdateGroup.class})
    private String author;
    
    @ApiModelProperty(value = "出版社",required=false)
    @Length(max=100,message = "出版社最大100个字符", groups = {AddGroup.class,UpdateGroup.class})
    private String publisher;
    
    @ApiModelProperty(value = "出版时间",required=false)
    private Date publishTime;
    
    @ApiModelProperty(value = "页数",required=false)
    private Integer pages;
    
    @ApiModelProperty(value = "译者",required=false)
    @Length(max=100,message = "译者最大100个字符", groups = {AddGroup.class,UpdateGroup.class})
    private String translator;
    
    
    @ApiModelProperty(value = "定价(单位:分)",required=false)
    private Integer price;
    
    @ApiModelProperty(value = "装订类型",required=true)
    private Integer bindingType;
    
    @ApiModelProperty(value = "文学体裁",required=true)
    private Integer genreType;
    
    @ApiModelProperty(value = "封面图片Id",required=true)
    @NotNull(message="封面图片不能为空", groups = {AddGroup.class,UpdateGroup.class})
    private Long coverId;
 
    @ApiModelProperty(value = "摘要",required=false)
    @Length(max=300,message = "摘要最大300个字符", groups = {AddGroup.class,UpdateGroup.class})
    private String summary;

    @ApiModelProperty(value = "作品简介",required=false)
    private String intro;

    @ApiModelProperty(value = "排序号",required=false)
    private Integer sort;
    
    public Long getWorksId() {
        return worksId;
    }

    public void setWorksId(Long worksId) {
        this.worksId = worksId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public Date getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public String getTranslator() {
        return translator;
    }

    public void setTranslator(String translator) {
        this.translator = translator;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Integer getBindingType() {
        return bindingType;
    }

    public void setBindingType(Integer bindingType) {
        this.bindingType = bindingType;
    }

    public Integer getGenreType() {
        return genreType;
    }

    public void setGenreType(Integer genreType) {
        this.genreType = genreType;
    }

    public Long getCoverId() {
        return coverId;
    }

    public void setCoverId(Long coverId) {
        this.coverId = coverId;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }
    
    public Offprint build(){
        Offprint offprint = new Offprint();
        offprint.setWorksId(worksId); 
        offprint.setName(name);
        offprint.setAuthor(author);
        offprint.setPublisher(publisher);
        offprint.setPublishTime(publishTime);
        offprint.setPages(pages);
        offprint.setTranslator(translator);
        offprint.setPrice(price);
        offprint.setBindingType(bindingType);
        offprint.setGenreType(genreType);
        offprint.setCoverId(coverId);
        offprint.setSummary(summary);
        offprint.setIntro(intro);
        offprint.setSort(sort);
        return offprint;
    }

}
